package com.dhcc.bpm.modules.metadata.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.List;

/**
 * @Title
 * @ClassName OpenApiParameter
 * @Desription
 * @Author zhangzexu
 * @Date 2020/5/30 13:57
 * @Version V1.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpenApiParameter {


    private String openapi;
    private Info info;
    private List<Servers> servers;
    private List<Tags> tags;
    private HashMap<String,Paths> paths;

    private Components components;


   // 文件属性开始

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Info{
        private String title;
        private String description;
        private String version;
    }

   // 文件属性开始
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Tags{
        private String name;
        private String description;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Servers{
        private String url;
        private String description;
    }

    // 文件属性结束
    // api 路径
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Paths{
        private Method post;
        private Method get;
        private Method put;
        private Method delete;
    }



    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Method{
        private String summary;
        private String description;
        private String operationId;
        private List<String> tags;
        private List<Parameters> parameters;
        private RequestBody requestBody;
        private HashMap<String,Responses> responses;
    }


//    请求参数
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Parameters{
        private String name;
        private String in;
        private String description;
        private boolean required;
        private Schema schema;

    }
    //    body
    @Data
    @Builder
    @AllArgsConstructor
    public static class RequestBody{
        private String description;
        private boolean required;
        private HashMap<String,RequestBodySchema> content;
    }

    //    响应数据格式
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Responses{
        private String description;
        private HashMap<String,RequestBodySchema> content;
    }

    //json 数据组装
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RequestBodySchema{
        private Schema schema;
    }

    //json 字段属性配置
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Schema{
        private String type;
        private Xml xml;
        private String format;
        private String ref;
        private Items items;
        private String Default;
        private String description;
        private List<Object> Enum;
    }

    // json 对象依赖

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Items{
        private String ref;
        private String type;
    }



    //属性组装标识开始

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Components{
        private HashMap<String,Schemas> schemas;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Schemas{
        private String type;
        private List<String> required;
        private String description;
        private HashMap<String,Schema> properties;
        private Xml xml;

    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Xml{
        private String name;
        private Boolean wrapped;
    }


















}
